package com.jxw.studyrecord;

import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import com.jxw.studyrecordprovider.util.StudyRecorderUtil;

/* loaded from: classes.dex */
public class StudyRecordMng {
    private static final long MIN_DURATION_TIME = 1200000;
    private static final String TAG = "StudyRecordMng";
    private static long mEnterTime = 0;
    private static long mExitTime = 0;
    private static boolean mInPrimarySchool = false;
    private static String mModulName;
    private static int mModulType;

    public static void startCount(Context context, String str, String str2, String str3, boolean z) {
        mInPrimarySchool = z;
        if (mInPrimarySchool) {
            mModulName = StudyRecordPrimaryNameEx.getName(str, str2, str3);
        } else {
            mModulName = StudyRecordMiddleName.getName(str, str2, str3);
        }
        if (TextUtils.isEmpty(mModulName)) {
            Log.i(TAG, "startCount(): do not need record");
        } else {
            mEnterTime = System.currentTimeMillis();
        }
    }

    public static void stopCount(Context context) {
        if (TextUtils.isEmpty(mModulName)) {
            return;
        }
        mExitTime = System.currentTimeMillis();
        if (MIN_DURATION_TIME <= mExitTime - mEnterTime) {
            if (mInPrimarySchool) {
                mModulType = 1;
            } else {
                mModulType = 2;
            }
            StudyRecorderUtil.insertStudyRecord(context, mModulName, mEnterTime, mExitTime, mModulType);
        } else {
            Log.i(TAG, "stopCount(): time is not enough, not record");
        }
        clearCount();
    }

    public static void clearCount() {
        mModulName = null;
    }
}
